import { format } from 'date-fns'
export default function myTime(time) {
    const now = Date.now()
    const target = new Date(time);
    const diff = now - target
    const MinuiteDiff = Math.floor(diff / 1000 / 60)
    if (MinuiteDiff == 0) {
        return `小于一分钟前`
    }
    else if (MinuiteDiff >= 1 && MinuiteDiff < 60) {
        return `${MinuiteDiff}分钟前`
    } else if (MinuiteDiff >= 60 && MinuiteDiff < 24 * 60) {
        return `${Math.floor(MinuiteDiff / 60)}小时前`
    } else if (MinuiteDiff >= 24 * 60 && MinuiteDiff < 24 * 60 * 7) {
        return `${Math.floor(MinuiteDiff / 24 / 60)}天前`
    }
    // return `123`
     return format(target, 'yyyy-MM-dd HH:mm:ss')
}